﻿<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<IList<int[]>>" %>

    <script type="text/javascript">
        var externalData;
        var externalChart;
        google.load("visualization", "1", { packages: ["corechart"] });
        google.setOnLoadCallback(drawChart);
        function drawChart() {
            var data = new google.visualization.DataTable();
            externalData = data;
            data.addColumn('string', 'Question');
            data.addColumn('number', 'Total');
            data.addColumn('number', 'Correct');
            data.addRows(<%= Model.Count %>);
            <% for (int i = 0; i < Model.Count; i++) { 
                int questionNumber = i + 1; %>
                data.setValue(<%= i %>, 0, '<%= "Q" + questionNumber.ToString() %>');
                data.setValue(<%= i %>, 1, <%= Model[i][0] %>);
                data.setValue(<%= i %>, 2, <%= Model[i][1] %>);
            <% } %> 

            var chart = new google.visualization.ColumnChart(document.getElementById('chartContainer'));
            externalChart = chart;
            chart.draw(data, { backgroundColor: '#EAF0F4', colors: ['blue', 'green'], width: 460, height: 100, legend: 'none', vAxis: { textPosition: 'none' }, chartArea: { top: 0, left: 0, width:"100%" } });
        }
    </script>